import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screen_util.dart';
import 'package:study_online/global/colors.dart';
import 'package:study_online/entity/TestItemEn.dart';
import 'package:flutter/material.dart';
import 'package:study_online/global/global.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
         backgroundColor: Colors.black26,
         title: Text('container'),
        ),
        body: TestItem(),
      ),
    );
  }
}
class TestItem extends StatelessWidget {
  TestItem({Key key,this.testItemEn}) : super(key: key);
  TestItemEn testItemEn;
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(
      BoxConstraints(
        maxWidth: MediaQuery.of(context).size.width,
        maxHeight: MediaQuery.of(context).size.height
      ),
      designSize: Size(1080,2340),
    );
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        SizedBox(height: ScreenUtil().setHeight(32),),
        Container(
          width: ScreenUtil().screenWidth-2*ScreenUtil().setWidth(20),
          height: ScreenUtil().setHeight(380),
          padding: EdgeInsets.fromLTRB(
            ScreenUtil().setWidth(31),
            ScreenUtil().setHeight(58),
            ScreenUtil().setWidth(31),
            ScreenUtil().setHeight(25),
          ),
          margin: EdgeInsets.fromLTRB(
            ScreenUtil().setWidth(9),
            ScreenUtil().setHeight(0),
            ScreenUtil().setWidth(9),
            ScreenUtil().setHeight(0),
          ),
          decoration: BoxDecoration(
            color:Color(0xffF7F7F7),
            borderRadius: BorderRadius.all(Radius.circular(10)),
            boxShadow: [
              BoxShadow(
                color: Colors.black26,
                offset: Offset(-2, 2.0),
                blurRadius: 2.0,
                spreadRadius: 0.6,
              ),
              BoxShadow(color:Color(0xffF7F7F7))
            ],
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                testItemEn.paTitle,
                style:TextStyle(
                  fontSize: ScreenUtil().setSp(56),
                  color:Colors.black,
                  fontWeight: FontWeight.bold,
                ),
              ),
              Text(
                testItemEn.timeLimit,
                style:TextStyle(
                  fontSize: ScreenUtil().setSp(36),
                  color:AppColors.subtext,
                ),
              ),
              Divider(height: ScreenUtil().setHeight(8),color: AppColors.subtext,),
              Row(
                children: [
                  Align(
                    alignment: Alignment.bottomLeft,
                    child: Text(
                      '共${testItemEn.proNum}题',
                      style:TextStyle(
                        fontSize: ScreenUtil().setSp(44),
                        color:AppColors.subtext,
                      ),
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.bottomRight,
                      child: InkWell(
                        onTap: (){
                          String stuId=Global.getInstance().user.stuId;
                          Navigator.pushNamed(context, 'test',arguments: [stuId,testItemEn.paId,testItemEn.paTitle]);
                        },
                        child: Container(
                          width: ScreenUtil().setWidth(250),
                          height: ScreenUtil().setHeight(83),
                          decoration: BoxDecoration(
                            color: AppColors.primary,
                            borderRadius: BorderRadius.all(Radius.circular(ScreenUtil().setHeight(83)*0.5)),
                          ),
                          child: Center(
                            child: Text(
                              '进入测试',
                              style:TextStyle(
                                fontSize: ScreenUtil().setSp(37),
                                color:Colors.white,
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              )
            ],
          ),
        ),
      ]
    );
  }
}
